<template>
	<xn-form-container
		:title="title"
		:width="900"
		:visible="visible"
		:destroy-on-close="true"
		@close="onClose"
		:bodyStylePadding="1"
	>
		<filePreview :src="url" :fileType="fileType" @goBack="onClose" />
	</xn-form-container>
</template>
<script setup name="flowFilePreview">
	import filePreview from '@/components/XnFilePreview/index.vue'
	const visible = ref(false)
	const title = ref('')
	const fileType = ref('')
	const url = ref('')

	const onOpen = (record) => {
		visible.value = true
		title.value = record.attachName
		fileType.value = record.attachName.split('.').pop()
		url.value = record.attachUrl
	}
	// 关闭抽屉
	const onClose = () => {
		visible.value = false
	}
	// 抛出函数
	defineExpose({
		onOpen
	})
</script>
